//
//  WJMainViewController.swift
//  WJWeiBo
//
//  Created by wangjun on 16/7/19.
//  Copyright © 2016年 wangjun. All rights reserved.
//

import UIKit

class WJMainViewController: UITabBarController {
    
    lazy var MainNavigationController: UINavigationController = UINavigationController()
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        let tabBar = WJMainTabBar()
        
        tabBar.closure = {
            
            let composeView = WJComposeView()
            composeView.composeShow(self)
//            let composeVC = WJComposeViewController()
//            self.presentViewController(UINavigationController(rootViewController: composeVC), animated: true, completion: nil)
        }
        
        setValue(tabBar, forKey: "tabBar")
        addTabBarItem("tabbar_home", title: "首页", vc: WJHomeViewController())
        addTabBarItem("tabbar_message_center", title: "消息", vc: WJMessageViewController())
        addTabBarItem("tabbar_discover", title: "发现", vc: WJDiscoverViewController())
        addTabBarItem("tabbar_profile", title: "我", vc: WJProfileViewController())
    }
    
    
    func addTabBarItem(imageName: String,title: String,vc: UIViewController) {
        
        
        vc.title = title
        
        vc.tabBarItem.image = UIImage(named: imageName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        vc.tabBarItem.selectedImage = UIImage(named: "\(imageName)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: UIControlState.Selected)
        
        addChildViewController(UINavigationController(rootViewController: vc))
        
    }
    

    
    
}
